package com.example.controller;

import com.example.bean.Position;
import com.example.service.PositionService;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
public class PositionController {

    @Autowired
    PositionService positionService;

    @RequestMapping("query")
    public List<Position> query(String positionName) throws IOException, SolrServerException {

        if(positionName == null){
            return null;
        }

        return positionService.queryPositions("positionName:"+positionName);
    }
}
